class ProImage < ActiveRecord::Base
  belongs_to :img_type
  belongs_to :product
  belongs_to :cart_item
  before_save :save_image
  attr_accessor :image
  
  protected
  def save_image
    unless @image.blank?
      #filename=CommonFunction.upload_file(@image,"/public/images/proimages/")
      #      self.image_name=ProImage.new(:name=>filename,:image_type_id=>1)
      #      filename_s=CommonFunction.get_thumnb("/public/images/proimgs/")
      #      ProImage.create()
      self.name=CommonFunction.upload_file(@image,"/public/images/proimages/")
      CommonFunction.get_thumnb("/public/images/proimages/#{self.name}",135)
    end
  end

end
